﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using MultiWindows.Codes;


namespace MultiWindows.Forms
{
    public partial class FormVideo : Form
    {
        public string url { get; set; }
        public bool bChangeVideo { get; set; }

        public FormVideo()
        {
            InitializeComponent();
        }

        private void FormVideo_Load(object sender, EventArgs e)
        {
            //TODO:
            this.bChangeVideo = false;
            Play();
        }

        public void Play()
        {
            //axWMP.
            this.axWMP.URL = url;
            if (this.axWMP.playState == WMPLib.WMPPlayState.wmppsPlaying)
            {
                this.axWMP.Ctlcontrols.stop();
            }
            
            this.axWMP.Ctlcontrols.play();
            //this.Invalidate();
        }



        private void FormVideo_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.axWMP.close();
            ((FormMain)this.ParentForm).SaveWindowState(Window.VIDEO, this.Height, this.Width, this.Top, this.Left);
        }

        private void axWMP_StatusChange(object sender, EventArgs e)
        {
            //if (axWMP.status.Contains("正在播放"))
            //{
            //    this.OnSizeChanged(e);
            //    this.axWMP.fullScreen = true;
            //    this.axWMP.stretchToFit = true;
            //}
        }

        private void axWMP_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
        {
            if (this.axWMP.playState == WMPLib.WMPPlayState.wmppsPlaying)
            {
                this.OnSizeChanged(new EventArgs());
                this.axWMP.fullScreen = true;
                this.axWMP.stretchToFit = true;
            }

            if (this.axWMP.playState == WMPLib.WMPPlayState.wmppsStopped && !this.bChangeVideo)
            {
                this.axWMP.Ctlcontrols.play();
            }
        }

        private void FormVideo_Click(object sender, EventArgs e)
        {
            MessageBox.Show(this.axWMP.playState.ToString());
        }

        private void FormVideo_DoubleClick(object sender, EventArgs e)
        {
            this.axWMP.Ctlcontrols.play();
        }

        private void FormVideo_MouseClick(object sender, MouseEventArgs e)
        {
            //MessageBox.Show(this.axWMP.playState.ToString());
            this.axWMP.Ctlcontrols.play();
        }


       
    }
}
